const __cv00_name = (index: number) => `Character Variant ${index}`;
const __ss00_name = (index: number) => `Stylistic Set ${index}`;

interface OpenTypeFeatureInfo {
  name: string;
  demo: string;
}

// OpenType features mapping from docs/reference/open-type-features.md
export const FEATURES: Record<string, OpenTypeFeatureInfo> = {
  aalt: { name: "Access All Alternates", demo: "Abc" },
  abvf: { name: "Above-base Forms", demo: "क + marks" },
  abvm: { name: "Above-base Mark Positioning", demo: "á" },
  abvs: { name: "Above-base Substitutions", demo: "क + marks" },
  afrc: { name: "Alternative Fractions", demo: "1/2 3/4" },
  akhn: { name: "Akhand", demo: "क्ष (Devanagari)" },
  apkn: { name: "Kerning for Alternate Proportional Widths", demo: "To AV" },
  blwf: { name: "Below-base Forms", demo: "क + nukta" },
  blwm: { name: "Below-base Mark Positioning", demo: "ạ" },
  blws: { name: "Below-base Substitutions", demo: "क + nukta" },
  c2pc: { name: "Petite Capitals From Capitals", demo: "ABC" },
  c2sc: { name: "Small Capitals From Capitals", demo: "ABC" },
  calt: { name: "Contextual Alternates", demo: "- -> --> = => ==>" },
  case: { name: "Case-sensitive Forms", demo: "(ABC)" },
  ccmp: { name: "Glyph Composition / Decomposition", demo: "á ö" },
  cfar: { name: "Conjunct Form After Ro", demo: "r + क" },
  chws: { name: "Contextual Half-width Spacing", demo: "カタカナ" },
  cjct: { name: "Conjunct Forms", demo: "क्ष" },
  clig: { name: "Contextual Ligatures", demo: "st" },
  cpct: { name: "Centered CJK Punctuation", demo: "。 「」" },
  cpsp: { name: "Capital Spacing", demo: "TITLE" },
  cswh: { name: "Contextual Swash", demo: "Q J" },
  curs: { name: "Cursive Positioning", demo: "السلام" },
  cv01: { name: __cv00_name(1), demo: "1 ①" },
  cv02: { name: __cv00_name(2), demo: "2 ②" },
  cv03: { name: __cv00_name(3), demo: "3 ③" },
  cv04: { name: __cv00_name(4), demo: "4 ④" },
  cv05: { name: __cv00_name(5), demo: "5 ⑤" },
  cv06: { name: __cv00_name(6), demo: "6 ⑥" },
  cv07: { name: __cv00_name(7), demo: "7 ⑦" },
  cv08: { name: __cv00_name(8), demo: "8 ⑧" },
  cv09: { name: __cv00_name(9), demo: "9 ⑨" },
  cv10: { name: __cv00_name(10), demo: "10 ⑩" },
  cv11: { name: __cv00_name(11), demo: "11 ⑪" },
  cv12: { name: __cv00_name(12), demo: "12 ⑫" },
  cv13: { name: __cv00_name(13), demo: "13 ⑬" },
  cv14: { name: __cv00_name(14), demo: "14 ⑭" },
  cv15: { name: __cv00_name(15), demo: "15 ⑮" },
  cv16: { name: __cv00_name(16), demo: "16 ⑯" },
  cv17: { name: __cv00_name(17), demo: "17 ⑰" },
  cv18: { name: __cv00_name(18), demo: "18 ⑱" },
  cv19: { name: __cv00_name(19), demo: "19 ⑲" },
  cv20: { name: __cv00_name(20), demo: "20 ⑳" },
  cv21: { name: __cv00_name(21), demo: "21 ㉑" },
  cv22: { name: __cv00_name(22), demo: "22 ㉒" },
  cv23: { name: __cv00_name(23), demo: "23 ㉓" },
  cv24: { name: __cv00_name(24), demo: "24 ㉔" },
  cv25: { name: __cv00_name(25), demo: "25 ㉕" },
  cv26: { name: __cv00_name(26), demo: "26 ㉖" },
  cv27: { name: __cv00_name(27), demo: "27 ㉗" },
  cv28: { name: __cv00_name(28), demo: "28 ㉘" },
  cv29: { name: __cv00_name(29), demo: "29 ㉙" },
  cv30: { name: __cv00_name(30), demo: "30 ㉚" },
  cv31: { name: __cv00_name(31), demo: "31 ㉛" },
  cv32: { name: __cv00_name(32), demo: "32 ㉜" },
  cv33: { name: __cv00_name(33), demo: "33 ㉝" },
  cv34: { name: __cv00_name(34), demo: "34 ㉞" },
  cv35: { name: __cv00_name(35), demo: "35 ㉟" },
  cv36: { name: __cv00_name(36), demo: "36 ㊱" },
  cv37: { name: __cv00_name(37), demo: "37 ㊲" },
  cv38: { name: __cv00_name(38), demo: "38 ㊳" },
  cv39: { name: __cv00_name(39), demo: "39 ㊴" },
  cv40: { name: __cv00_name(40), demo: "40 ㊵" },
  cv41: { name: __cv00_name(41), demo: "41 ㊶" },
  cv42: { name: __cv00_name(42), demo: "42 ㊷" },
  cv43: { name: __cv00_name(43), demo: "43 ㊸" },
  cv44: { name: __cv00_name(44), demo: "44 ㊹" },
  cv45: { name: __cv00_name(45), demo: "45 ㊺" },
  cv46: { name: __cv00_name(46), demo: "46 ㊻" },
  cv47: { name: __cv00_name(47), demo: "47 ㊼" },
  cv48: { name: __cv00_name(48), demo: "48 ㊽" },
  cv49: { name: __cv00_name(49), demo: "49 ㊾" },
  cv50: { name: __cv00_name(50), demo: "50 ㊿" },
  cv51: { name: __cv00_name(51), demo: "51 ㊱" },
  cv52: { name: __cv00_name(52), demo: "52 ㊲" },
  cv53: { name: __cv00_name(53), demo: "53 ㊳" },
  cv54: { name: __cv00_name(54), demo: "54 ㊴" },
  cv55: { name: __cv00_name(55), demo: "55 ㊵" },
  cv56: { name: __cv00_name(56), demo: "56 ㊶" },
  cv57: { name: __cv00_name(57), demo: "57 ㊷" },
  cv58: { name: __cv00_name(58), demo: "58 ㊸" },
  cv59: { name: __cv00_name(59), demo: "59 ㊹" },
  cv60: { name: __cv00_name(60), demo: "60 ㊺" },
  cv61: { name: __cv00_name(61), demo: "61 ㊻" },
  cv62: { name: __cv00_name(62), demo: "62 ㊼" },
  cv63: { name: __cv00_name(63), demo: "63 ㊽" },
  cv64: { name: __cv00_name(64), demo: "64 ㊾" },
  cv65: { name: __cv00_name(65), demo: "65 ㊿" },
  cv66: { name: __cv00_name(66), demo: "66 ㊱" },
  cv67: { name: __cv00_name(67), demo: "67 ㊲" },
  cv68: { name: __cv00_name(68), demo: "68 ㊳" },
  cv69: { name: __cv00_name(69), demo: "69 ㊴" },
  cv70: { name: __cv00_name(70), demo: "70 ㊵" },
  cv71: { name: __cv00_name(71), demo: "71 ㊶" },
  cv72: { name: __cv00_name(72), demo: "72 ㊷" },
  cv73: { name: __cv00_name(73), demo: "73 ㊸" },
  cv74: { name: __cv00_name(74), demo: "74 ㊹" },
  cv75: { name: __cv00_name(75), demo: "75 ㊺" },
  cv76: { name: __cv00_name(76), demo: "76 ㊻" },
  cv77: { name: __cv00_name(77), demo: "77 ㊼" },
  cv78: { name: __cv00_name(78), demo: "78 ㊽" },
  cv79: { name: __cv00_name(79), demo: "79 ㊾" },
  cv80: { name: __cv00_name(80), demo: "80 ㊿" },
  cv81: { name: __cv00_name(81), demo: "81 ㊱" },
  cv82: { name: __cv00_name(82), demo: "82 ㊲" },
  cv83: { name: __cv00_name(83), demo: "83 ㊳" },
  cv84: { name: __cv00_name(84), demo: "84 ㊴" },
  cv85: { name: __cv00_name(85), demo: "85 ㊵" },
  cv86: { name: __cv00_name(86), demo: "86 ㊶" },
  cv87: { name: __cv00_name(87), demo: "87 ㊷" },
  cv88: { name: __cv00_name(88), demo: "88 ㊸" },
  cv89: { name: __cv00_name(89), demo: "89 ㊹" },
  cv90: { name: __cv00_name(90), demo: "90 ㊺" },
  cv91: { name: __cv00_name(91), demo: "91 ㊻" },
  cv92: { name: __cv00_name(92), demo: "92 ㊼" },
  cv93: { name: __cv00_name(93), demo: "93 ㊽" },
  cv94: { name: __cv00_name(94), demo: "94 ㊾" },
  cv95: { name: __cv00_name(95), demo: "95 ㊿" },
  cv96: { name: __cv00_name(96), demo: "96 ㊱" },
  cv97: { name: __cv00_name(97), demo: "97 ㊲" },
  cv98: { name: __cv00_name(98), demo: "98 ㊳" },
  cv99: { name: __cv00_name(99), demo: "99 ㊴" },
  dist: { name: "Distances", demo: "To AV" },
  dlig: { name: "Discretionary Ligatures", demo: "ct st" },
  dnom: { name: "Denominators", demo: "1/2" },
  dtls: { name: "Dotless Forms", demo: "i j" },
  expt: { name: "Expert Forms", demo: "ct st" },
  falt: { name: "Final Glyph on Line Alternates", demo: "word" },
  fin2: { name: "Terminal Forms #2", demo: "سلام" },
  fin3: { name: "Terminal Forms #3", demo: "سلام" },
  fina: { name: "Terminal Forms", demo: "سلام" },
  flac: { name: "Flattened Accent Forms", demo: "â ê ô" },
  frac: { name: "Fractions", demo: "1/2 3/4" },
  fwid: { name: "Full Widths", demo: "ABC123" },
  half: { name: "Half Forms", demo: "क" },
  haln: { name: "Halant Forms", demo: "क्" },
  halt: { name: "Alternate Half Widths", demo: "カタカナ" },
  hist: { name: "Historical Forms", demo: "ſ" },
  hkna: { name: "Horizontal Kana Alternates", demo: "カタカナ" },
  hlig: { name: "Historical Ligatures", demo: "ct st" },
  hngl: { name: "Hangul", demo: "한글" },
  hojo: { name: "Hojo Kanji Forms", demo: "亜 唖" },
  hwid: { name: "Half Widths", demo: "ＡＢＣ" },
  init: { name: "Initial Forms", demo: "سلام" },
  isol: { name: "Isolated Forms", demo: "س" },
  ital: { name: "Italics", demo: "abc" },
  jalt: { name: "Justification Alternates", demo: "— —" },
  jp04: { name: "JIS2004 Forms", demo: "旧" },
  jp78: { name: "JIS78 Forms", demo: "旧" },
  jp83: { name: "JIS83 Forms", demo: "旧" },
  jp90: { name: "JIS90 Forms", demo: "旧" },
  kern: { name: "Kerning", demo: "To AV" },
  lfbd: { name: "Left Bounds", demo: "AV" },
  liga: { name: "Standard Ligatures", demo: "fi fl ffi" },
  ljmo: { name: "Leading Jamo Forms", demo: "가" },
  lnum: { name: "Lining Figures", demo: "1234567890" },
  locl: { name: "Localized Forms", demo: "i İ" },
  ltra: { name: "Left-to-right Alternates", demo: "→" },
  ltrm: { name: "Left-to-right Mirrored Forms", demo: "→" },
  mark: { name: "Mark Positioning", demo: "á ö" },
  med2: { name: "Medial Forms #2", demo: "سلام" },
  medi: { name: "Medial Forms", demo: "سلام" },
  mgrk: { name: "Mathematical Greek", demo: "∑ ∆ π" },
  mkmk: { name: "Mark to Mark Positioning", demo: "ā́" },
  mset: { name: "Mark Positioning via Substitution", demo: "à́" },
  nalt: { name: "Alternate Annotation Forms", demo: "a" },
  nlck: { name: "NLC Kanji Forms", demo: "令" },
  nukt: { name: "Nukta Forms", demo: "क़" },
  numr: { name: "Numerators", demo: "1/2" },
  onum: { name: "Oldstyle Figures", demo: "1234567890" },
  opbd: { name: "Optical Bounds", demo: "AV" },
  ordn: { name: "Ordinals", demo: "No." },
  ornm: { name: "Ornaments", demo: "❦ ✤" },
  palt: { name: "Proportional Alternate Widths", demo: "1234" },
  pcap: { name: "Petite Capitals", demo: "Abc" },
  pkna: { name: "Proportional Kana", demo: "カタカナ" },
  pnum: { name: "Proportional Figures", demo: "123456" },
  pref: { name: "Pre-base Forms", demo: "क" },
  pres: { name: "Pre-base Substitutions", demo: "क" },
  pstf: { name: "Post-base Forms", demo: "क" },
  psts: { name: "Post-base Substitutions", demo: "क" },
  pwid: { name: "Proportional Widths", demo: "１２３" },
  qwid: { name: "Quarter Widths", demo: "１２３" },
  rand: { name: "Randomize", demo: "text" },
  rclt: { name: "Required Contextual Alternates", demo: "th" },
  rkrf: { name: "Rakar Forms", demo: "क्र" },
  rlig: { name: "Required Ligatures", demo: "lam-alef" },
  rphf: { name: "Reph Form", demo: "र्" },
  rtbd: { name: "Right Bounds", demo: "AV" },
  rtla: { name: "Right-to-left Alternates", demo: "←" },
  rtlm: { name: "Right-to-left Mirrored Forms", demo: "←" },
  ruby: { name: "Ruby Notation Forms", demo: "漢(かん)" },
  rvrn: { name: "Required Variation Alternates", demo: "a" },
  salt: { name: "Stylistic Alternates", demo: "a g" },
  sinf: { name: "Scientific Inferiors", demo: "H2O" },
  size: { name: "Optical Size", demo: "Text" },
  smcp: { name: "Small Capitals", demo: "abc" },
  smpl: { name: "Simplified Forms", demo: "國 → 国" },
  ss01: { name: __ss00_name(1), demo: "a g" },
  ss02: { name: __ss00_name(2), demo: "a g" },
  ss03: { name: __ss00_name(3), demo: "a g" },
  ss04: { name: __ss00_name(4), demo: "a g" },
  ss05: { name: __ss00_name(5), demo: "a g" },
  ss06: { name: __ss00_name(6), demo: "a g" },
  ss07: { name: __ss00_name(7), demo: "a g" },
  ss08: { name: __ss00_name(8), demo: "a g" },
  ss09: { name: __ss00_name(9), demo: "a g" },
  ss10: { name: __ss00_name(10), demo: "a g" },
  ss11: { name: __ss00_name(11), demo: "a g" },
  ss12: { name: __ss00_name(12), demo: "a g" },
  ss13: { name: __ss00_name(13), demo: "a g" },
  ss14: { name: __ss00_name(14), demo: "a g" },
  ss15: { name: __ss00_name(15), demo: "a g" },
  ss16: { name: __ss00_name(16), demo: "a g" },
  ss17: { name: __ss00_name(17), demo: "a g" },
  ss18: { name: __ss00_name(18), demo: "a g" },
  ss19: { name: __ss00_name(19), demo: "a g" },
  ss20: { name: __ss00_name(20), demo: "a g" },
  ssty: { name: "Math Script-style Alternates", demo: "x y" },
  stch: { name: "Stretching Glyph Decomposition", demo: "ــ" },
  subs: { name: "Subscript", demo: "x2" },
  sups: { name: "Superscript", demo: "x2" },
  swsh: { name: "Swash", demo: "Q J" },
  titl: { name: "Titling", demo: "Title" },
  tjmo: { name: "Trailing Jamo Forms", demo: "ᆨ" },
  tnam: { name: "Traditional Name Forms", demo: "舊" },
  tnum: { name: "Tabular Figures", demo: "123456" },
  trad: { name: "Traditional Forms", demo: "國" },
  twid: { name: "Third Widths", demo: "１２３" },
  unic: { name: "Unicase", demo: "Aa" },
  valt: { name: "Alternate Vertical Metrics", demo: "カタカナ" },
  vapk: {
    name: "Kerning for Alternate Proportional Vertical Metrics",
    demo: "カタカナ",
  },
  vatu: { name: "Vattu Variants", demo: "क" },
  vchw: { name: "Vertical Contextual Half-width Spacing", demo: "カタカナ" },
  vert: { name: "Vertical Alternates", demo: "漢字" },
  vhal: { name: "Alternate Vertical Half Metrics", demo: "カタカナ" },
  vjmo: { name: "Vowel Jamo Forms", demo: "ᅡ" },
  vkna: { name: "Vertical Kana Alternates", demo: "カタカナ" },
  vkrn: { name: "Vertical Kerning", demo: "カナ" },
  vpal: { name: "Proportional Alternate Vertical Metrics", demo: "カタカナ" },
  vrt2: { name: "Vertical Alternates and Rotation", demo: "漢字" },
  vrtr: { name: "Vertical Alternates for Rotation", demo: "漢字" },
  zero: { name: "Slashed Zero", demo: "0" },
} as const;

export type OpentypeFeatureTag = keyof typeof FEATURES;
